mui.init();
var VM ;
mui.plusReady(function () {
    VM = new Vue({
        el: '#QUEdata',
        data: {
            history_list: [],
            tabIndex: 1
        },
        mounted: function () {
            showWatting();
            var api_host = plus.storage.getItem('HOST_URL');
            mui.ajax({
                url: api_host + '/api/questionbank/public/get_user_question_history',
                dataType: 'json',
                headers:{'User-Token':plus.storage.getItem('UserToken')},
                timeout:3000,
                type: 'get',
                success: function (msg) {
                    if (msg.code == 1) {
                        VM.history_list = msg.data;
                    } else {
                        mui.toast(msg.msg, {duration: '200',type: 'div'});
                    }
                },
                error: function (xhr, type, errorThrown) {
                    mui.toast('加载失败请重试!', {duration: '200',type: 'div'});
                },
                complete:function () {
                    plus.nativeUI.closeWaiting();
                }
            });
        },
        methods: {
            open_history_detail: function (type, id) {
                if (type == 3) {
                    mui.openWindow({
                        url: 'oneTestPaperAnalysis.html',
                        extras: {
                            'catid': id
                        },
                        createNew: false,
                        show: {
                            autoShow: true,
                            aniShow: 'pop-in',
                            duration: 400
                        },
                        waiting: {
                            autoShow: false,
                        }
                    });
                } else {
                    mui.openWindow({
                        url: 'exercisesHistoryDetail.html',
                        extras: {
                            'catid': id,
                            'type': type
                        },
                        createNew: false,
                        show: {
                            autoShow: true,
                            aniShow: 'pop-in',
                            duration: 400
                        },
                        waiting: {
                            autoShow: false,
                        }
                    });
                }
            }
        }
    })
})

mui('.mui-slider').on('tap', '.history', function () {
    VM.tabIndex = $(this).attr('data-index');
})